#ifndef _CAMERA_PROJECTION_H
#define _CAMERA_PROJECTION_H

#include <Eigen/Dense>
#include <opencv2/opencv.hpp>
#include <ros/ros.h>
#include <sensor_msgs/CameraInfo.h>
#include <sensor_msgs/Image.h>
#include <migratable_rl/detect.h>

class CameraProjection{
public:
    CameraProjection(const Eigen::Matrix4d& extrinsic_matrix,std::string& camera_name,bool view_image);
    
    void image_callback(const sensor_msgs::ImageConstPtr& msg);

    void camerainfo_callback(const sensor_msgs::CameraInfoConstPtr& msg);

    void reset_vector();

    void distance_normal(std::vector<double>& distance);

    void visualize_point(cv::Mat& image,const migratable_rl::detectResponse& detect_result);
    
    void set_detect_client(ros::ServiceClient& client);

    void points_projection(std::vector<Eigen::Vector3d>& points);

    int point_projection(Eigen::Vector3d& point);

private:

    void show_bounding_box(cv::Mat&image,migratable_rl::detectResponse& detect_result);

    int in_boundingbox(cv::Point2i& p,const migratable_rl::boundingbox& bounding_box);


private:
    Eigen::Matrix3d camera_matrix_;
    Eigen::Matrix4d extrinsic_matrix_;

    bool view_image_;
    bool camera_info_init_;
    int image_height_;
    int image_width_;

    std::string window_name_;
    ros::ServiceClient detect_client;

    cv::Mat current_image_;
    std::vector<cv::Point3i> image_position_;
    std::vector<int> type_;

    migratable_rl::boundingbox detect_result_;
};


#endif